﻿<UserControl
    x:Class="WinRTXamlToolkit.Debugging.Views.VisualTreeView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:WinRTXamlToolkit.Debugging.Views"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:controls="using:WinRTXamlToolkit.Controls"
    xmlns:data="using:WinRTXamlToolkit.Controls.Data"
    mc:Ignorable="d"
    d:DesignHeight="300"
    d:DesignWidth="400">
    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary
                    Source="ms-appx:///WinRTXamlToolkit.Debugging/Themes/SharedResources.xaml" />
            </ResourceDictionary.MergedDictionaries>
            <ResourceDictionary.ThemeDictionaries>
                <ResourceDictionary
                    x:Key="Default">
                    <SolidColorBrush
                        x:Key="ToolStripBackground"
                        Color="#FF2C2C2C" />
                    <SolidColorBrush
                        x:Key="ToolBarButtonBackground"
                        Color="#FF444444" />
                </ResourceDictionary>
                <ResourceDictionary
                    x:Key="Light">
                    <SolidColorBrush
                        x:Key="ToolStripBackground"
                        Color="#FFD3D3D3" />
                    <SolidColorBrush
                        x:Key="ToolBarButtonBackground"
                        Color="#FFBBBBBB" />
                </ResourceDictionary>
            </ResourceDictionary.ThemeDictionaries>
            <DataTemplate
                x:Key="DependencyPropertyDetailsTemplate">
                <local:DependencyObjectDetailsView />
            </DataTemplate>
            <DataTemplate
                x:Key="DefaultDetailsTemplate">
                <Grid>
                    <TextBlock
                        TextWrapping="Wrap"
                        VerticalAlignment="Top"
                        Text="{Binding Description}" />
                </Grid>
            </DataTemplate>
            <local:VisualTreeViewItemDetailsTemplateSelector
                x:Key="VisualTreeViewItemDetailsTemplateSelector"
                DependencyPropertyDetailsTemplate="{StaticResource DependencyPropertyDetailsTemplate}"
                DefaultDetailsTemplate="{StaticResource DefaultDetailsTemplate}" />
        </ResourceDictionary>
    </UserControl.Resources>
    <Grid
        Background="{ThemeResource ToolBarButtonBackground}">
        <Grid.RowDefinitions>
            <RowDefinition />
            <RowDefinition
                Height="Auto" />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition />
            <ColumnDefinition
                Width="Auto" />
            <ColumnDefinition />
        </Grid.ColumnDefinitions>
        <controls:TreeView
            x:Name="treeView"
            ItemsSource="{Binding RootElements}"
            IsSelectedBindingPath="IsSelected"
            IsExpandedBindingPath="IsExpanded"
            BorderThickness="0"
            Padding="0">
            <controls:TreeView.ItemTemplate>
                <DataTemplate>
                    <data:DataTemplateExtensions.Hierarchy>
                        <data:HierarchicalDataTemplate
                            ItemsSource="{Binding Children}" />
                    </data:DataTemplateExtensions.Hierarchy>
                    <TextBlock
                        FontWeight="{Binding FontWeight}"
                        Text="{Binding DisplayName}" />
                </DataTemplate>
                <!--<data:HierarchicalDataTemplate
                    ItemsSource="{Binding Children}">
                    <StackPanel
                        Orientation="Horizontal">
                        <TextBlock
                            Text="{Binding Text}" />
                        <Ellipse
                            VerticalAlignment="Center"
                            Margin="5"
                            Width="10"
                            Height="10"
                            Fill="{Binding Brush}" />
                    </StackPanel>
                </data:HierarchicalDataTemplate>-->
            </controls:TreeView.ItemTemplate>
        </controls:TreeView>
        <controls:CustomGridSplitter
            Grid.Column="1"
            Grid.RowSpan="2"
            IsTabStop="False" />
        <ContentControl
            Grid.Column="2"
            Grid.RowSpan="2"
            Content="{Binding SelectedItem}"
            HorizontalContentAlignment="Stretch"
            VerticalContentAlignment="Stretch"
            ContentTemplateSelector="{StaticResource VisualTreeViewItemDetailsTemplateSelector}" />
        <StackPanel
            Grid.Row="1">
            <controls:ToolStrip
                Background="{ThemeResource ToolBarButtonBackground}">
                <controls:ToolBarButton
                    x:Name="RefreshButton"
                    Content="Refresh"
                    Click="OnRefreshButtonClick" />
                <controls:ToolBarButton
                    x:Name="SelectFocusedButton"
                    Content="Select Focused"
                    Click="OnSelectFocusedClick"
                    IsTabStop="False" />
                <controls:ToolBarButton
                    x:Name="FocusSelectedButton"
                    Content="Focused Selected"
                    Click="OnFocusSelectedClick"
                    IsTabStop="False" />
                <controls:ToolBarToggleButton
                    x:Name="FocusTrackerButton"
                    Content="Track Focus"
                    Click="OnFocusTrackerButtonClick"
                    IsTabStop="False" />
            </controls:ToolStrip>
            <TextBlock
                Text="Hover with Ctrl+Shift to select element."
                VerticalAlignment="Bottom" />
        </StackPanel>
    </Grid>
</UserControl>
